import { getMsbdListApi, deleteMsbdApi, AddMsbdApi, } from '../../api/audit/index'
export const state = () => ({
    tableData: [],
    page: {
        PageSize: 2,
        currerPage: 1,
        total: 100,
    },
    options: [],
})

export const mutations = {
    MSBD_LIST(state, tableData) {
        state.tableData = tableData
    },
    MSBD_PAGE(state, currerPage) {
        state.page.currerPage = currerPage
    },
    MSBD_SIZE(state, PageSize) {
        state.page.PageSize = PageSize
    },
    MSBD_TOTAL(state, total) {
        state.page.total = total
    },
    GETOPTIONS(state, options) {
        state.options = options;
    },
}
export const actions = {
    // 获取列表
    async getMsbd({ commit, state }) {
        const r = await getMsbdListApi({ pageSize: state.page.PageSize, currentPage: state.page.currerPage - 1 })
        commit('GETOPTIONS', r.data.classify)
        commit('MSBD_LIST', r.data.data)
        commit('MSBD_TOTAL', r.total)
    },

    //删除列表
    async deleteMsbd({ dispatch }, id) {
        console.log(id);
        const r = await deleteMsbdApi({ id })
        dispatch('getMsbd')
    },

    //新增列表
    async addMsbd({ dispatch }, form) {
        const r = await AddMsbdApi(form)
        console.log(r);
        dispatch('getMsbd')
    }
}

export const getters = {

}